﻿Imports DAO
Imports DTO

Public Class TheLoaiBUS

    Public Shared Function ThemTheLoai(ByVal tl As TheLoaiDTO) As Boolean
        If TheLoaiDAO.GetTheLoaiByName(tl.TenTheLoai) Is Nothing Then
            TheLoaiDAO.Insert(tl)
            Return True
        Else
            Return False
        End If
    End Function

    Public Shared Function XoaTheLoai(ByVal tl As TheLoaiDTO) As Boolean
        If TheLoaiDAO.GetTheLoaiByName(tl.TenTheLoai) IsNot Nothing Then
            TheLoaiDAO.Delete(tl)
            Return True
        Else
            Return False
        End If
    End Function

    Public Shared Function SuaTheLoai(ByVal tl As TheLoaiDTO) As Boolean
        If TheLoaiDAO.GetTheLoaiByMa(tl.MaTheLoai) IsNot Nothing Then
            TheLoaiDAO.Update(tl)
            Return True
        Else
            Return False
        End If
    End Function
End Class
